Repository navigation
fix: honour falsy json values in beforeRequest/beforeResponse overrides - #234
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
buildOverriddenBody ignored json overrides of false, 0, '' and null because it checked truthiness instead of undefined.
|
|
pimterry
approved these changes
Nov 19, 2026
pimterry
left a comment
Member
There was a problem hiding this comment.
Code looks good to me. Can you sign the CLA please? Then this is ready to merge.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
buildOverriddenBodychose thejsonoverride withif (callbackResult?.json), so a callback returning{ json: false },{ json: 0 },{ json: '' }or{ json: null }was treated as "no override": the original body was kept and nocontent-typewas set.jsonis typed as accepting any JSON value (CallbackRequestResult.json,CallbackResponseMessageResult.json), so these are valid.The check is now
!== undefined, matching howbodyis handled just below and how the callback handler already treatsjson(result.json !== undefinedinrequest-step-impls.ts).true, objects and the unset case behave as before.Reproduction
A passthrough rule with
beforeResponse: () => ({ json: false })(ornull,0,'') forwards the upstream body unchanged on main. At the function level,buildOverriddenBody({ json: false }, headers)returnsundefinedon main and afalsebody with this change.Test
New
test/passthrough-handling.spec.tscovers false, 0, "", null, true, an object, and no override. 4 fail before the fix, all 7 pass after.This PR was prepared with AI assistance (Claude Code) and the contributor is responsible for its contents.